﻿@{
    Layout = null;
}
@model List<ElingOA6_Admin_DSJCJ.Model.DocRefImp>
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
        <script src="../../../../Scripts/json2.js" type="text/javascript"></script>  
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

)
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    )
    <style>
        .fixedTable
{
	table-layout: fixed;
}
    .subTitle
{
	text-overflow:ellipsis;
	overflow:hidden;
	white-space: nowrap;
	padding:1px;
	font-size:12px;
}
    </style>
    <script type="text/javascript">
        var conditionModel = null; //信息查询条件实体类
        var queryParam = new Array();
        $(function () {
            $("#toolMenu").smartFloat();
            conditionModel = JSON.parse($("#hdDocQueryCondition").val());
            var txtQuery_Title = ASPxClientTextBox.Cast("txtQuery_Title");
            txtQuery_Title.SetValue(conditionModel.FTitle);
        });

        function OnBeginCallback(s, e) {
            e.customArgs["command"] = e.command;
            e.customArgs["pageIndex"] = s.pageIndex;
            e.customArgs["pageCount"] = s.pageCount;
            e.customArgs["pageRowSize"] = s.pageRowSize;
            e.customArgs["pageRowCount"] = s.pageRowCount;
            e.customArgs["docClsCd"] = $("#hdDocClsCd").val();
            e.customArgs["queryCondition"] = JSON.stringify(conditionModel);
        }
//        /*获取文档查询条件*/
//        function getQueryCondition() {
//            return conditionModel;
//        }
//        /*设置文档查询条件*/
//        function setQueryCondition(tmpConditionModel) {
//            conditionModel = tmpConditionModel;
//            documentQueryModalMode.Hide();
//            var clientFStatusObj = ASPxClientComboBox.Cast("FStatus");
//            if (clientFStatusObj.GetValue() != conditionModel.FStatus) {
//                clientFStatusObj.SetValue(conditionModel.FStatus);
//                FStatus_ValueChanged(clientFStatusObj);
//            }
//            else {
//                var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
//                clientgvDocumentObj.Refresh();
//            }
        //        }

        /*查询*/
        function query() {
            var txtQuery_Title = ASPxClientTextBox.Cast("txtQuery_Title");
            conditionModel.FTitle = txtQuery_Title.GetValue();
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            clientgvDocumentObj.Refresh();
        }

        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnCancelRef":
                    {
                        //取消引用
                        cancelRefMany();
                        break;
                    }
            }
        }

       
        /*批量取消引用*/
        function cancelRefMany() {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            var docIdArray = clientgvDocumentObj.GetSelectedKeysOnPage();
            if (docIdArray.length == 0) {
                alert("请选择需要取消引用的数据");
            }
            else {
                var docIds = "";
                for (var i = 0; i < docIdArray.length; i++) {
                    docIds += docIdArray[i] + ",";
                }
                docIds = docIds.substring(0, docIds.lastIndexOf(','));
                cancelRef(docIds);
            }
        }

        /*取消引用*/
        function cancelRef(keyValues) {
            var clientgvDocumentObj = ASPxClientGridView.Cast("gvDocument");
            if (confirm("确定取消所选信息的引用吗？")) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/DocRefImp/CancelDocRef',
                    data: { keyValues: keyValues },
                    success: function (jsonstr) {
                        var msg = jsonstr.split('|');
                        if (msg[0] == "SUCCESS") {
                            alert("取消引用成功");
                            //刷新
                            clientgvDocumentObj.Refresh();
                            clientgvDocumentObj.UnselectAllRowsOnPage();
                        }
                        else {
                            if (msg.length > 1) {
                                alert(msg[1]);
                            }
                        }
                    }
                });
            }
        }

    </script>

</head>
<body>
    <div class="floatToolMenu" id="toolMenu">
        @Html.DevExpress().Menu(settings =>
   {
       settings.Name = "toolBarMenu";
       settings.ItemAutoWidth = false;
       settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
       settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
       settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

       
       settings.Items.Add(item =>
       {
           item.Name = "btnCancelRef";
           item.Text = "取消引用";
           item.ItemStyle.ForeColor = System.Drawing.Color.Red;
           item.ClientEnabled = true;
           item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

       });
       settings.Items.Add(item =>
       {
           item.SetTemplateContent(c =>
           {
               ViewContext.Writer.Write("<table  cellpadding='0' cellspacing='1'><tr><td>&nbsp;&nbsp;</td><td>");
               
               @Html.DevExpress().Label(settings1 =>
               {
                   settings1.Text = "标题:";
                   settings1.ControlStyle.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
               }).GetHtml();
               ViewContext.Writer.Write("</td>");
               ViewContext.Writer.Write("<td>");
               @Html.DevExpress().TextBox(settings1 =>
                                {
                                    settings1.Name = "txtQuery_Title";
                                    settings1.Width = 150;
                                    settings1.Text = "";
                                }).GetHtml();
               ViewContext.Writer.Write("</td>");
               ViewContext.Writer.Write("<td>&nbsp;</td>");
               ViewContext.Writer.Write("<td>");
               @Html.DevExpress().Button(settings1 =>
              {
                  settings1.Name = "btnQuery";
                  settings1.Text = "查询";
                  settings1.ControlStyle.CssClass = "tableToolBar";
                  settings1.Images.Image.Url = Url.Content("~/Content/ControlImages/query.png");
                  settings1.ClientSideEvents.Click = "query";
              }).GetHtml();
               ViewContext.Writer.Write("</td>");
               ViewContext.Writer.Write("</tr></table>");
           });

       });
      
       settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
       settings.ItemLinkMode = ItemLinkMode.ContentBounds;
   }).GetHtml()
    </div>

    @Html.Partial("DocumentListPartial", Model)
    @Html.Hidden("hdDocClsCd", ViewData["docClsModel"] != null ? (ViewData["docClsModel"] as ElingOA6_Admin_DSJCJ.Model.DocCls).FDocClsCd : "")
    @Html.Hidden("hdDocQueryCondition", ViewData["docQueryCondition"] == null ? "" : ViewData["docQueryCondition"].ToString())@*查询条件*@
    @Html.Hidden("hdPageIndex", ViewData["pageIndex"] == null ? 1 : int.Parse(ViewData["pageIndex"].ToString()))
</body>
</html>
